<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\MessageSended
 *
 * @property int $id
 * @property int $type 目标用户类型1全部2注册用户3有效用户
 * @property int $template_id 模板id
 * @property int $user_id 用户id
 * @property int $sender_id 发送者id
 * @property string|null $key_word 关键字
 * @property string $url 超链接
 * @property string $title 消息标题
 * @property string $content 消息内容
 * @property string $desc 说明
 * @property int $status 已读状态 1已读 0未读
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereDesc($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereKeyWord($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereSenderId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereTemplateId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\MessageSended whereUserId($value)
 * @mixin \Eloquent
 */
class MessageSended extends Model
{
    protected $fillable = [
        'type',
        'template_id',
        'user_id',
        'title',
        'content',
        'key_word',
        'status',
        'url',
        'sender_id',
        'desc',
    ];

    /**
     * 全部用户
     */
    const TARGET_ALL = 1;
    /**
     * 授信成功以及之前的用户
     */
    const TARGET_APPLY = 2;
    /**
     * 放款成功以及之后的用户
     */
    const TARGET_LOAN = 3;

    /**
     * 已读
     */
    const STATUS_READ = 1;

    /**
     * 未读
     */
    const STATUS_NOT_READ = 0;

    /**
     * 有效用户数组
     */
    static $user_group = [
        self::TARGET_APPLY => [
            UserGlobal::STATUS_NOTHING,  //未申请授信
            UserGlobal::STATUS_LOAN_REQUEST, //授信申请未提交
            UserGlobal::STATUS_LOAN_REQUEST_FAILED, //授信申请失败
            UserGlobal::STATUS_LOAN_REQUEST_SUCCESS, //授信申请成功
            UserGlobal::STATUS_LOAN_TIME_OUT, //授信申请超时
            UserGlobal::STATUS_LOAN_RESTART, //授信申请完全超时
            UserGlobal::STATUS_LOAN_MONEY_PROCESSING,//放款申请
            UserGlobal::STATUS_LOAN_MONEY_FAIL, //放款失败
            UserGlobal::STATUS_LOAN_CHANGE_CARD, //放款失败换卡

        ],
        self::TARGET_LOAN =>[
            UserGlobal::STATUS_REPAY_INIT,//开始还款
            UserGlobal::STATUS_REPAY_ING, //
            UserGlobal::STATUS_REPAY_SUCCESS,
            UserGlobal::STATUS_REPAY_FAILURE,
            UserGlobal::STATUS_REPAY_OVER,
        ],
    ];
}
